var pathName = window.document.location.pathname;
var locat = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
/*选择模板加载对于模板数据*/
function retrieval(url){
		$.ajax({
			url : url,
        	type:'post',
        	dataType:"json",
        	success:function(data){
        		var jsondatas=eval("("+data.jsondatas.jsondata+")");
        		$("#tbody").html("");
        		 $.each(jsondatas,function(index,item){ 
        			 var ix = 0; //查询出来的顺序
        			 var inp = "";//文本框HTML代码
        			 var iseye="";//是否显示字段
        			 var inputtype="";//inputtype 文本框类型
        			 var name = "";//类型名字
        			 var sort = "";//排序类型 
        			 var inputin ="";//输入信息
            		 $.each(item,function(i,it){
            			if(ix==0){
            				 name=i;
             				inp+="<input type='text' class='form-control ' name="+i+" onchange='input(this);' value="+it+" readonly='readonly'  />";
             				 inp+="<input type='hidden' class='form-control ' name="+name+"  onchange='input(this);'  value='0'  />";
             			 }else{
             				 if(ix!=3){
             					 inp+="<input type='hidden' class='form-control ' name="+name+" onchange='input(this);' value="+it+"  />";
             				 }else{
             					 inp+="<input type='hidden' class='form-control sort ' name="+name+" onchange='input(this);' value="+it+"  />";
             				 }
             				
             				 if(ix==2){
             					 if(it ==1){
             						iseye="<span class='glyphicon glyphicon-eye-open'   style='color: #63B8FF'>";
             					 }else{
             						iseye="<span class='glyphicon glyphicon-eye-close'></span>";
             					 }
             				 }else if(ix==1){
             					inputtype="<span class='glyphicon "+it+"'   style='color: #63B8FF'></span>";
             					if(it == "icon-file-alt"){
                					//文本框
             						inputin = "<input type='text' class='form-control ' name="+name+" value=''  />";
                				}else if(it == "icon-time"){
                					//系统时间
                					inputin = "<input type='text' class='form-control ' name="+name+" value='系统自动填充'  readonly='readonly'  onFocus='WdatePicker()'  />";
                				}else if(it == "icon-user"){
                					//操作员工
                					inputin = "<input type='text' class='form-control ' name="+name+" value='系统自动填充'  readonly='readonly'  />";
                				}else if(it == "icon-link"){
                					//网址链接
                					inputin = "<input type='text' class='form-control ' name="+name+" value='https://'  />";
                				}else if(it == "icon-tablet"){
                					//电话号码
                					inputin = "<input type='text' class='form-control ' onchange='phone(this)' name='"+name+"' value=''  />";
                				}else if(it == "icon-picture"){
                					//添加图片
                					inputin = "<input type='text' class='form-control ' name="+name+" value='点击上传'  readonly='readonly' onclick='fileupload(this);'  /><input type='file' class='form-control ' name="+name+" value='' style='display: none;'  accept='image/*'  onchange='fileuploads(event,this)'  />";
                				}else if(it == "icon-folder-close-alt"){
                					inputin = "<input type='text' class='form-control ' name="+name+" value='点击上传'  readonly='readonly' onclick='fileupload(this);'  /><input type='file' class='form-control ' name="+name+" value='' style='display: none;' onchange='fileuploads(event,this)'  />";
                				}
             				 }
             			 }
            			 var htmls = "<tr>"
 							+"<td>"+inp+"</td>"
							+"<td>"+inputin+"</td>"
							+"<td>"
							+"		<button type='button' class='btn btn-xs' onclick='deltr(this);' >"
							+"        	<span class='glyphicon glyphicon-trash'  style='color: #63B8FF'></span>"
							+"        </button>"
							+"</td>"
							+"<td>"
							+"		<button type='button' class='btn btn-xs' onclick='upbth(this);' >"
							+"        	<span class='glyphicon glyphicon-chevron-up upbtn'  style='color: #63B8FF'></span>"
							+"        </button>"
							+"</td>"
							+"<td>"
							+"		<button type='button' class='btn btn-xs' onclick='downbtn(this);' >"
							+"        	<span class='glyphicon glyphicon-chevron-down downbtn'  style='color: #63B8FF'></span>"
							+"        </button>"
							+"</td>"
							+"<td>"
							+"		<button type='button' class='btn btn-xs'  onclick='eye(this);'>"
							+iseye
							+"        </button>"
							+"</td>"
							+"<td><button type='button' class='btn btn-xs'  onclick='filexuanz(this);'>"
							+inputtype
							+"      </button>"
							+"</td>"
							+"</tr>";
            			 if(ix==3){
            				 if($("#tbody tr").html()==null){
            				 $("#tbody").prepend(htmls);
            				 }else{
            					 	var $bss=0;
            					   $("input.sort").each(function (i) {
            							if($(this).val()>it){
            								$(this).parents("tr").before(htmls);
            									$bss=1;
            									return false;
            							}
            						});
            					   if($bss==0){
            						   $("#tbody").append(htmls);
        							}
            				 }
            			 }
            			ix++;
            		 });
            	 });
        	}
        });
		$("div.panel-info").show();
	}

/*实现自定义添加列*/
function pageaddterm(){
	var trLength =$("button .upbtn").length;
	$("#tbody").append("<tr>"
			+"<td><input type='text' class='form-control ' name='' onchange='input(this);'  />"
			+"<input type='hidden' class='form-control ' name='' value='0'  />"
			+"<input type='hidden' class='form-control ' name='' value='icon-file-alt'  />"
			+"<input type='hidden' class='form-control ' name=''  value='1' />"
			+"<input type='hidden' class='form-control sort' name='' value='"+trLength+"'  /></td>"
			+"<td><input type='text' class='form-control' name='' value=''  /></td>"
			+"<td>"
			+"		<button type='button' class='btn btn-xs' onclick='deltr(this);' >"
			+"        	<span class='glyphicon glyphicon-trash'  style='color: #63B8FF'></span>"
			+"        </button>"
			+"</td>"
			+"<td>"
			+"		<button type='button' class='btn btn-xs' onclick='upbth(this);' >"
			+"        	<span class='glyphicon glyphicon-chevron-up upbtn'  style='color: #63B8FF'></span>"
			+"        </button>"
			+"</td>"
			+"<td>"
			+"		<button type='button' class='btn btn-xs' onclick='downbtn(this);' >"
			+"        	<span class='glyphicon glyphicon-chevron-down downbtn'  style='color: #63B8FF'></span>"
			+"        </button>"
			+"</td>"
			+"<td>"
			+"		<button type='button' class='btn btn-xs'  onclick='eye(this);'>"
			+"        	<span class='glyphicon glyphicon-eye-open'   style='color: #63B8FF'></span>"
			+"        </button>"
			+"</td>"
			+"<td><button type='button' class='btn btn-xs'  onclick='filexuanz(this);'>"
			+"       <span class='glyphicon icon-file-alt'   style='color: #63B8FF'></span>"
			+"      </button>"
			+"</td>"
			+"</tr>");
}

function updatepageinitterm(jsondatas){
	 $.each(jsondatas,function(index,item){ 
		 var ix = 0; //查询出来的顺序
		 var inp = "";//文本框HTML代码
		 var iseye="";//是否显示字段
		 var inputtype="";//inputtype 文本框类型
		 var name = "";//类型名字
		 var sort = "";//排序类型 
		 var valueinput = "";
		 var typeint = "";
		 $.each(item,function(i,it){
			 if(ix==0){
				 name=i;
				 inp+="<input type='text' class='form-control ' name="+i+" onchange='input(this);' value="+it+" readonly='readonly'  />";
			 }else{
				  if(ix==4){
					 sort = it;
					 inp+="<input type='hidden' class='form-control sort ' name="+name+" onchange='input(this);' value="+it+"  />";
				 }else if(ix==5){
					 if(typeint=="icon-picture"){
						 valueinput="<input type='text' class='form-control ' name="+name+" value="+it+"  readonly='readonly' onclick='viewimg(this);'  /><input type='file' class='form-control ' name="+name+" value='' style='display: none;'  accept='image/*'  onchange='fileuploads(event,this)'  />";
					 }else if(typeint=="icon-folder-close-alt"){
						 valueinput="<input type='text' class='form-control ' name="+name+" value="+it+"  readonly='readonly' onclick='viewimg(this);'  /><input type='file' class='form-control ' name="+name+" value='' style='display: none;'  onchange='fileuploads(event,this)'  />";
					 }else if(typeint=="icon-user"){
						 valueinput ="<input type='text' class='form-control ' name="+name+" value="+it+"  readonly='readonly'  />";
					 }else if(typeint=="icon-time"){
						 valueinput ="<input type='text' class='form-control ' name="+name+" value="+it+"  readonly='readonly'  onFocus='WdatePicker()' />";
					 }else if(typeint=="icon-tablet"){
						 valueinput ="<input type='text' class='form-control '  onchange='phone(this)'  name='"+name+"' value='"+it+"' />"; 
					 } else{
						 valueinput ="<input type='text' class='form-control ' name="+name+" value='"+it+"' />";
					 }
				 }else{
					 inp+="<input type='hidden' class='form-control ' name="+name+" onchange='input(this);' value='"+it+"'  />";
				 }
			 }
			 if(ix==3){
				 if(it ==1){
					iseye="<span class='glyphicon glyphicon-eye-open'   style='color: #63B8FF'>";
				 }else{
					iseye="<span class='glyphicon glyphicon-eye-close'></span>";
				 }
			 }else if(ix==2){
				typeint=it;
				inputtype="<span class='glyphicon "+it+"'   style='color: #63B8FF'></span>";
			 }
			 var htmls = "<tr>"
				+"<td>"+inp+"</td>"
				+"<td>"+valueinput+"</td>"
				+"<td>"
				+"		<button type='button' class='btn btn-xs' onclick='deltr(this);' >"
				+"        	<span class='glyphicon glyphicon-trash'  style='color: #63B8FF'></span>"
				+"        </button>"
				+"</td>"
				+"<td>"
				+"		<button type='button' class='btn btn-xs' onclick='upbth(this);' >"
				+"        	<span class='glyphicon glyphicon-chevron-up upbtn'  style='color: #63B8FF'></span>"
				+"        </button>"
				+"</td>"
				+"<td>"
				+"		<button type='button' class='btn btn-xs' onclick='downbtn(this);' >"
				+"        	<span class='glyphicon glyphicon-chevron-down downbtn'  style='color: #63B8FF'></span>"
				+"        </button>"
				+"</td>"
				+"<td>"
				+"		<button type='button' class='btn btn-xs'  onclick='eye(this);'>"
				+iseye
				+"        </button>"
				+"</td>"
				+"<td><button type='button' class='btn btn-xs'  onclick='filexuanz(this);'>"
				+inputtype
				+"      </button>"
				+"</td>"
				+"</tr>";
			 if(ix==5){
				 if($("#tbody tr").html()==null){
				 $("#tbody").prepend(htmls);
				 }else{
					 	var $bss=0;
					   $("input.sort").each(function (i) {
							if($(this).val()>sort){
								$(this).parents("tr").before(htmls);
									$bss=1;
									return false;
							}
						});
					   if($bss==0){
						   $("#tbody").append(htmls);
						}
				 }
			 }
			ix++;
		 });
	 });
}

/*删除列*/
function deltr(obj){
	  $(obj).parent("td").parent("tr").remove();
	  $("input.sort").each(function (i) {
			$(this).val(i);
		});
}

/*修改是否可见*/
function eye(obj){
	if($(obj).parent("td").siblings().eq(0).children().eq(3).val()==0){
		$(obj).parent("td").siblings().eq(0).children().eq(3).val("1");
		$(obj).html("<span class='glyphicon glyphicon-eye-open'   style='color: #63B8FF'></span>");
	}else{
		$(obj).parent("td").siblings().eq(0).children().eq(3).val("0");
		$(obj).html("<span class='glyphicon glyphicon-eye-close'></span>");
	}
}

/*选择input类型*/
function filexuanz(obj){
	  var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="类型设置";
		 diag.URL =locat+"/goodstemplate/inputType?id=&quot;"+$(obj).parent("td").siblings().eq(0).children().eq(2).val()+"&quot;";
		 diag.Width = 400;
		 diag.Height = 284;
		 diag.CancelEvent = function(){ //关闭事件
			 if(diag.innerFrame.contentWindow.document.getElementById('buttype').value==1){
				 var namevalue = diag.innerFrame.contentWindow.document.getElementById('inputtype').value;
				$(obj).html("<span class='glyphicon "+namevalue+"'   style='color: #63B8FF'></span>");
				$(obj).parent("td").siblings().eq(0).children().eq(2).val(namevalue);
				if(namevalue == "icon-file-alt"){
					//文本框
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("type","text");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("placeholder");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("readonly");
					$(obj).parent("td").siblings().eq(1).children().eq(1).remove();
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("onclick");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("onchange");
					$(obj).parent("td").siblings().eq(1).children().eq(0).val("");
				}else if(namevalue == "icon-time"){
					//系统时间
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("type","text");
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("placeholder","系统时间");
					$(obj).parent("td").siblings().eq(1).children().eq(0).val("系统自动填充");
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("readonly","readonly");
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("onFocus","WdatePicker()");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("onchange");
					$(obj).parent("td").siblings().eq(1).children().eq(1).remove();
				}else if(namevalue == "icon-user"){
					//操作员工
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("type","text");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("accept");
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("placeholder","操作员工");
					$(obj).parent("td").siblings().eq(1).children().eq(0).val("操作员工");
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("readonly","readonly");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("onclick");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("onchange");
					$(obj).parent("td").siblings().eq(1).children().eq(1).remove();
				}else if(namevalue == "icon-link"){
					//网址链接
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("type","text");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("accept");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("placeholder");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("readonly");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("onclick");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("onchange");
					$(obj).parent("td").siblings().eq(1).children().eq(0).val("http://");
					$(obj).parent("td").siblings().eq(1).children().eq(1).remove();
				}else if(namevalue == "icon-tablet"){
					//电话号码
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("type","text");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("placeholder");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("readonly");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("onclick");
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("onchange","phone(this);");
					$(obj).parent("td").siblings().eq(1).children().eq(0).val("");
					$(obj).parent("td").siblings().eq(1).children().eq(1).remove();
				}else if(namevalue == "icon-picture"){
					//添加图片before
						var $ss = $(obj).parent("td").siblings().eq(1).children().eq(0).attr("name");
						$(obj).parent("td").siblings().eq(1).children().eq(0).attr("type","text");
						$(obj).parent("td").siblings().eq(1).children().eq(0).attr("readonly","readonly");
						$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("placeholder");
						$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("onchange");
						$(obj).parent("td").siblings().eq(1).children().eq(0).val("点击上传");
						$(obj).parent("td").siblings().eq(1).children().eq(0).attr("onclick","fileupload(this)");
						$(obj).parent("td").siblings().eq(1).children().eq(1).remove();
						$(obj).parent("td").siblings().eq(1).children().eq(0).after("<input type='file' class='form-control ' name='"+$ss+"'  value='' style='display: none;' accept='image/*' onchange='fileuploads(event,this)'  />");
				}else if(namevalue == "icon-folder-close-alt"){
					//添加文件before
					var $ss = $(obj).parent("td").siblings().eq(1).children().eq(0).attr("name");
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("type","text");
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("readonly","readonly");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("placeholder");
					$(obj).parent("td").siblings().eq(1).children().eq(0).removeAttr("onchange");
					$(obj).parent("td").siblings().eq(1).children().eq(0).val("点击上传");
					$(obj).parent("td").siblings().eq(1).children().eq(0).attr("onclick","fileupload(this)");
					$(obj).parent("td").siblings().eq(1).children().eq(1).remove();
					$(obj).parent("td").siblings().eq(1).children().eq(0).after("<input type='file' class='form-control ' name='"+$ss+"'  value='' style='display: none;' onchange='fileuploads(event,this)'  />");
				}
		 }
			diag.close();
		 };
		 diag.show();
 }


function input(obj){
	$.ajax({
		 url: locat+'/goodstemplate/tofirst?value='+$(obj).val(),
         type: 'post',
         success: function (data) {
        	 if($('input[name="'+data+'"]').size()==0){
        		 $(obj).attr("name",data);
        		 $(obj).parent("td").siblings().eq(0).children().eq(0).attr("name",data);
        		 $(obj).parent("td").siblings().eq(0).children().eq(1).attr("name",data);
            	 $(obj).siblings().attr("name",data);
        	 }else{
        		 $(obj).tips({
						side : 3,
						msg : '存在该字段',
						bg : '#AE81FF',
						time : 1
						});
        		 	$(obj).val("");
						$(obj).focus();
						return;	
        	 }
         }
	});    	
}



//上移
function upbth(obj){
	var $tr = $(obj).parents("tr");
		if ($tr.index() != 0) {
			$tr.prev().before($tr);
			$("input.sort").each(function (i) {
				$(this).val(i);
			});
		}
	}

	//下移
	function downbtn(obj) {
		var trLength = $("button .downbtn").length; 
		var $tr = $(obj).parents("tr"); 
		if ($tr.index() != trLength - 1) { 
			$tr.next().after($tr);
			$("input.sort").each(function (i) {
				$(this).val(i);
			});
		}
	}
	
	function phone(obj){
		if(!mobile($(obj).val(),obj)){
			$(obj).val("");
			$(obj).blur();
			return;	
		}
	};

	function spmc(obj){
		$("#SPMCVAL").val($(obj).val());
	}
	
	function getFileSize(evt) {
		
		var files = evt.target.files;
			  var imgele = new Image();
			  var thesrc = window.URL.createObjectURL(files[0]);
			  $("#imglist1p").hide();
			  $("#imglist").show();
			  $("#imgshow").attr("src",thesrc);
	}
	
	//点击图片
	function fileupload(obj){
		$(obj).siblings().eq(0).click();
	}
	
	//查看图片
	function viewimg(obj){
		var files =$(obj).siblings().eq(0).prop('files');
		var url = "";
		if(files[0]==null){
			var id =$(obj).parent("td").siblings().eq(0).children().eq(1).val();
		    var types  =$(obj).parent("td").siblings().eq(0).children().eq(1).attr("name");
			$.ajax({
				 url:locat+ '/filestorage/getimglist',
				 data:{"id":id,"attributetype":types},
	             type: 'post',
	             success: function (data) {
	            	 $.each(data,function(i,it){
	            		 if(it.flieType==".jpg" || it.flieType==".gif" || it.flieType==".png"){
	            			 swal({
				     	    	    title: "",
				     	    	    text: it.flieName,
				     	    	    imageUrl: locat+"/static/upload/"+it.flieName,
				     	    	    imageSize:"300x300",
				     	    	    showCancelButton: true,
				     	    	    confirmButtonText: "重新上传",
				     	    	    animation:"slide-from-bottom",
				     	    	    cancelButtonText:"取消",
				     	    	    closeOnConfirm: true
				     	    	},function (){
				     	    		$(obj).siblings().eq(0).click();
				     	    	});
	            		 }else{
	            			 swal({
				     	    	    title: "",
				     	    	    text: "<a href='"+locat+"/static/upload/"+it.flieName+"'>"+it.flieName+"</a>",
				     	    	   html:"<a href='"+locat+"/static/upload/"+it.flieName+"'>"+it.flieName+"</a>" ,
				     	    	    imageSize:"300x300",
				     	    	    showCancelButton: true,
				     	    	    confirmButtonText: "重新上传",
				     	    	    animation:"slide-from-bottom",
				     	    	    cancelButtonText:"取消",
				     	    	    closeOnConfirm: true
				     	    	},function (){
				     	    		$(obj).siblings().eq(0).click();
				     	    	});
	            		 }
	            		
	            	 });
	             }
			});   
		}else{
			if($(obj).siblings().eq(0).attr("accept")){
				swal({
		    	    title: "",
		    	    text: "",
		    	    imageUrl: window.URL.createObjectURL(files[0]),
		    	    imageSize:"300x300",
		    	    showCancelButton: true,
		    	    confirmButtonText: "重新上传",
		    	    animation:"slide-from-bottom",
		    	    cancelButtonText:"取消",
		    	    closeOnConfirm: true
		    	},function (){
		    		$(obj).siblings().eq(0).click();
		    	});
			}else{
				swal({
     	    	    title: "",
     	    	    text: "<a href='"+window.URL.createObjectURL(files[0])+"'>"+window.URL.createObjectURL(files[0])+"</a>",
     	    	   html:"<a href='"+window.URL.createObjectURL(files[0])+"'>"+window.URL.createObjectURL(files[0])+"</a>" ,
     	    	    imageSize:"300x300",
     	    	    showCancelButton: true,
     	    	    confirmButtonText: "重新上传",
     	    	    animation:"slide-from-bottom",
     	    	    cancelButtonText:"取消",
     	    	    closeOnConfirm: true
     	    	},function (){
     	    		$(obj).siblings().eq(0).click();
     	    	});
			}
			
		}
	}
	//添加图片及文件 
	function fileuploads(evt,obj){
		if($(obj).attr("accept")){
			$(obj).siblings().eq(0).val("查看图片");
		}else{
			$(obj).siblings().eq(0).val("查看文件");
		}
		$(obj).siblings().eq(0).attr("onclick","viewimg(this)");
		var files = evt.target.files;
	    var thesrc = window.URL.createObjectURL(files[0]);
		$("#imgshow").attr("src",thesrc);
	}
	
	
	function retrievalnode(url){
		$.ajax({
			url : url,
        	type:'post',
        	dataType:"json",
        	success:function(data){
        		var jsondatas=eval("("+data.tablejsonfield.jsonValue+")");
        		$("#tbody").html("");
        		 $.each(jsondatas,function(index,item){ 
        			 var ix = 0; //查询出来的顺序
        			 var inp = "";//文本框HTML代码
        			 var iseye="";//是否显示字段
        			 var inputtype="";//inputtype 文本框类型
        			 var name = "";//类型名字
        			 var sort = "";//排序类型 
        			 var inputin ="";//输入信息
            		 $.each(item,function(i,it){
            			if(ix==0){
            				 name=i;
             				inp+="<input type='text' class='form-control ' name="+i+" onchange='input(this);' value="+it+" readonly='readonly'  />";
             				 inp+="<input type='hidden' class='form-control ' name="+name+"  onchange='input(this);'  value='0'  />";
             			 }else{
             				 if(ix!=3){
             					 inp+="<input type='hidden' class='form-control ' name="+name+" onchange='input(this);' value="+it+"  />";
             				 }else{
             					 inp+="<input type='hidden' class='form-control sort ' name="+name+" onchange='input(this);' value="+it+"  />";
             				 }
             				
             				 if(ix==2){
             					 if(it ==1){
             						iseye="<span class='glyphicon glyphicon-eye-open'   style='color: #63B8FF'>";
             					 }else{
             						iseye="<span class='glyphicon glyphicon-eye-close'></span>";
             					 }
             				 }else if(ix==1){
             					inputtype="<span class='glyphicon "+it+"'   style='color: #63B8FF'></span>";
             					if(it == "icon-file-alt"){
                					//文本框
             						inputin = "<input type='text' class='form-control ' name="+name+" value=''  />";
                				}else if(it == "icon-time"){
                					//系统时间
                					inputin = "<input type='text' class='form-control ' name="+name+" value='系统自动填充'  readonly='readonly'  onFocus='WdatePicker()'  />";
                				}else if(it == "icon-user"){
                					//操作员工
                					inputin = "<input type='text' class='form-control ' name="+name+" value='系统自动填充'  readonly='readonly'  />";
                				}else if(it == "icon-link"){
                					//网址链接
                					inputin = "<input type='text' class='form-control ' name="+name+" value='https://'  />";
                				}else if(it == "icon-tablet"){
                					//电话号码
                					inputin = "<input type='text' class='form-control ' onchange='phone(this)' name='"+name+"' value=''  />";
                				}else if(it == "icon-picture"){
                					//添加图片
                					inputin = "<input type='text' class='form-control ' name="+name+" value='点击上传'  readonly='readonly' onclick='fileupload(this);'  /><input type='file' class='form-control ' name="+name+" value='' style='display: none;'  accept='image/*'  onchange='fileuploads(event,this)'  />";
                				}else if(it == "icon-folder-close-alt"){
                					inputin = "<input type='text' class='form-control ' name="+name+" value='点击上传'  readonly='readonly' onclick='fileupload(this);'  /><input type='file' class='form-control ' name="+name+" value='' style='display: none;' onchange='fileuploads(event,this)'  />";
                				}
             				 }
             			 }
            			 var htmls = "<tr>"
 							+"<td>"+inp+"</td>"
							+"<td>"+inputin+"</td>"
							+"<td>"
							+"		<button type='button' class='btn btn-xs' onclick='deltr(this);' >"
							+"        	<span class='glyphicon glyphicon-trash'  style='color: #63B8FF'></span>"
							+"        </button>"
							+"</td>"
							+"<td>"
							+"		<button type='button' class='btn btn-xs' onclick='upbth(this);' >"
							+"        	<span class='glyphicon glyphicon-chevron-up upbtn'  style='color: #63B8FF'></span>"
							+"        </button>"
							+"</td>"
							+"<td>"
							+"		<button type='button' class='btn btn-xs' onclick='downbtn(this);' >"
							+"        	<span class='glyphicon glyphicon-chevron-down downbtn'  style='color: #63B8FF'></span>"
							+"        </button>"
							+"</td>"
							+"<td>"
							+"		<button type='button' class='btn btn-xs'  onclick='eye(this);'>"
							+iseye
							+"        </button>"
							+"</td>"
							+"<td><button type='button' class='btn btn-xs'  onclick='filexuanz(this);'>"
							+inputtype
							+"      </button>"
							+"</td>"
							+"</tr>";
            			 if(ix==3){
            				 if($("#tbody tr").html()==null){
            				 $("#tbody").prepend(htmls);
            				 }else{
            					 	var $bss=0;
            					   $("input.sort").each(function (i) {
            							if($(this).val()>it){
            								$(this).parents("tr").before(htmls);
            									$bss=1;
            									return false;
            							}
            						});
            					   if($bss==0){
            						   $("#tbody").append(htmls);
        							}
            				 }
            			 }
            			ix++;
            		 });
            	 });
        	}
        });
		$("div.panel-info").show();
	}
	
	function inputIsNull(){
		var bool = true;
		var bs = 0;
    	$("table input[type!='file']").each(function(){
    		if($(this).attr("name")==""){
    			bs=1;
    		}
    		if($(this).val()=="" || $(this).val()=="点击上传"){
    			bs=2;
    		}
    		$(this).blur();
        })
        if(bs==1){
        	alert("列表名称不能为空");
        	bool= false;
        }
    	 if(bs==2){
            	alert("列表内容不能为空");
            	bool= false;
            }
    	 return bool;
	}